﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using SD.Database.Classes;
using System.Collections.Generic;

namespace SD.Database
{
    public partial class StoredProcedures
    {
        public static void CreateGame()
        {
            string t = Configuration.GetConfigurationForOption("MaxNumberOfSystems");
            int MaxNumberOfSystems = int.Parse(t);
            WorldCreator wc = new WorldCreator();
            NameGenerator ng = new NameGenerator();
            for (int i = 1; i <= MaxNumberOfSystems; i++)
            {
                List<int> tmp = wc.NextSystem();
                if (CheckIfSystemExists(tmp[0], tmp[1]) == false)
                    CreateSystem(tmp[0], tmp[1], ng.NextName());
                else
                {//try again
                    i = i - 1;
                }
            }

            int minPlanets = int.Parse(Configuration.GetConfigurationForOption("MinNumberOfPlanetsPerSystem"));
            int maxPlanets = int.Parse(Configuration.GetConfigurationForOption("MaxNumberOfPlanetsPerSystem"));
            Random r = new Random();
            for (int i = 1; i <= MaxNumberOfSystems; i++)
            {
                CreatePlanets(i, r.Next(minPlanets, maxPlanets));
            }

        }
    };
}